﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebClient;
using DTO;

namespace WebClient.admin.Modules.cart
{
    public partial class AddNew : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.btnAddNew.Attributes.Add("onclick", "return OnSubmitClick();");
            this.btnCancel.Attributes.Add("onclick", "return ClearAll()");
        }

        private void AddItem()
        {
            WebData data = new WebData();
            Cart item = new Cart();
            //item.id = this.txtid.Text.Trim();
            item.customersId = Convert.ToInt64(this.txtcustomersId.Text.Trim());
            item.address = this.txtaddress.Text.Trim();
            item.create_on = Convert.ToDateTime(this.txtcreate_on.Text.Trim());
            item.total = 1;
            item.discount = 0;
            item.payment = 0;
            item.arrears = 0;
            item.credit = this.txtcredit.Text.Trim();
            item.status = Convert.ToInt32(this.txtstatus.Text.Trim());
            item.orderId = Convert.ToInt32(this.txtorderId.Text.Trim());
            item.isActive = Convert.ToInt32(this.txtisActive.Text.Trim());
            item.fullName = this.txtfullName.Text.Trim();
            item.phone = this.txtphone.Text.Trim();
            data.OnSubmitCart(ref item, 0);
        }

        protected void btnAddNew_Click(object sender, EventArgs e)
        {
            AddItem();
        }
    }
}